import { toRefs as m, openBlock as g, createElementBlock as d, normalizeClass as f, unref as u, toDisplayString as h } from "vue";
const b = (e, t) => {
  const n = e.__vccOpts || e;
  for (const [o, c] of t)
    n[o] = c;
  return n;
}, x = {
  name: "XiaobuButton"
}, M = /* @__PURE__ */ Object.assign(x, {
  props: {
    type: {
      type: String,
      default: "normal"
    },
    text: {
      type: String,
      default: "button"
    }
  },
  emits: ["click"],
  setup(e, { emit: t }) {
    const n = e, { type: o, text: c } = m(n), l = t, y = (i) => {
      l("click", i);
    };
    return (i, w) => (g(), d("button", {
      class: f(["btn", "btn-" + u(o)]),
      onClick: y
    }, h(u(c)), 3));
  }
}), s = /* @__PURE__ */ b(M, [["__scopeId", "data-v-822e82ea"]]);
s.install = function(e) {
  e.component(s.name, s);
};
const v = function(e) {
  alert(`hello ${e}!`);
}, _ = function(e) {
  alert(`goodbye ${e}!`);
}, p = {
  date: "yyyy-MM-dd",
  month: "yyyy-MM",
  datetime: "yyyy-MM-dd hh:mm:ss",
  time: "hh:mm:ss",
  year: "yyyy"
}, k = (e) => {
  const t = e.replaceAll("-", "/");
  var n = new Date(e), o = new Date(t);
  return !isNaN(n.getTime()) || !isNaN(o.getTime());
}, D = (e, t = "datetime", n) => {
  if (!e || !t)
    return n ?? "";
  Object.keys(p).includes(t) && (t = p[t]), e instanceof Date || (typeof e == "number" || k(e) ? e = new Date(e) : e = new Date(Number(e)));
  const o = {
    "M+": e.getMonth() + 1,
    "d+": e.getDate(),
    "h+": e.getHours(),
    "m+": e.getMinutes(),
    "s+": e.getSeconds(),
    "q+": Math.floor((e.getMonth() + 3) / 3),
    S: e.getMilliseconds()
  };
  /(y+)/.test(t) && (t = t.replace(RegExp.$1, String(e.getFullYear()).substr(4 - RegExp.$1.length)));
  for (const c in o) {
    const l = new RegExp(`(${c})`);
    l.test(t) && (t = t.replace(l, RegExp.$1.length === 1 ? o[c] : ("00" + o[c]).substr(String(o[c]).length)));
  }
  return t;
}, r = {
  beforeMount(e, { value: t }) {
    e.$value = t.text, e.handler = () => {
      if (!e.$value) {
        console.log("无复制内容"), t.errorFn && t.errorFn();
        return;
      }
      const n = document.createElement("textarea");
      n.readOnly = "readonly", n.style.position = "absolute", n.style.left = "-9999px", n.value = e.$value, document.body.appendChild(n), n.select(), document.execCommand("Copy") && (console.log("复制成功"), t.successFn && t.successFn()), document.body.removeChild(n);
    }, e.addEventListener("click", e.handler);
  },
  // 当传进来的值更新的时候触发
  updated(e, { value: t }) {
    e.$value = t.text;
  },
  // 指令与元素解绑的时候，移除事件绑定
  unmounted(e) {
    e.removeEventListener("click", e.handler);
  }
};
r.install = function(e) {
  e.directive("copy", r);
};
const a = {
  mounted(e, t) {
    const n = new RegExp(t.value.replaceText, "g");
    e.innerHTML = e.innerHTML.replace(n, t.value.replaceContent);
  }
};
a.install = function(e) {
  e.directive("replace", a);
};
const C = s, F = [s], R = _, B = v, T = D, N = r, H = a, S = [
  {
    name: "copy",
    function: r
  },
  {
    name: "replace",
    function: a
  }
], $ = {
  async install(e) {
    $.install.installed || (F.map((t) => e.component(t.name, t)), S.map((t) => {
      e.directive(t.name, t.function);
    }));
  }
};
export {
  N as Copy,
  T as FormatDateFilter,
  H as Replace,
  R as SayGoodBye,
  B as SayHello,
  C as XiaobuButton,
  $ as default
};
